
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding:10px">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td   width="6" height="6"><img src="images/j_crn_tl_med.png" width="6" height="6" /></td>
            <td  background="images/j_crn_t_med.png" width="100%"></td>
            <td  width="6" height="6" ><img src="images/j_crn_tr_med.png" width="6" height="6" /></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="1" background="images/dot.png"></td>
            <td class="bg_title"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/icon-48-menumgr.png" width="48" height="48" /></td>
                <td width="45%" class="mana_title"> <?=$stitlestring?></td>
                <td width="50%" align="center">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="65%">&nbsp;</td>
                      <td class="icon_style" ><a href="index.php?progid=6&services=them"><img src="images/icon-32-new.png" width="32" height="32" border="0"/><br />
                      Th&ecirc;m</a></td>
                      
                     <td class="icon_style"><a href="#" onclick="return doSaveJobs('index.php?progid=6&services=xoa','Vui lòng chọn một bản ghi từ danh sách bên dưới')" ><img src="images/icon-32-delete.png" width="32" height="32"  border="0"/><br />
                      X&oacute;a</a></td>
                      <td class="icon_style"><a href="#"><img src="images/icon-32-help.png" width="32" height="32"  border="0"/><br />
                      Tr&#7907; gi&uacute;p</a></td>
                    </tr>
                  </table>
                  </td>
              </tr>
            </table></td>
            <td width="1" background="images/dot.png"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" height="6" ><img src="images/j_crn_bl_med.png" width="6" height="6" /></td>
            <td  background="images/j_crn_b_med.png" width="100%"></td>
            <td width="6" height="6" ><img src="images/j_crn_br_med.png" width="6" height="6" /></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="7"></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td   width="6" height="6"><img src="images/j_crn_tl_med.png" width="6" height="6" /></td>
            <td  background="images/j_crn_t_med.png" width="100%"></td>
            <td  width="6" height="6" ><img src="images/j_crn_tr_med.png" width="6" height="6" /></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="1" background="images/dot.png"></td>
            <td bgcolor="#fbfbfb"><form id="frmdanhsach" name="frmdanhsach" method="post" action="">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>
                  Tìm theo tên&nbsp;
                  <input type="text" name="txtsearch" id="txtsearch" value="<?php echo $_POST['txtsearch'];?>" />
                  &nbsp;
                  Tìm theo ngày hết hạn &nbsp;|&nbsp;&nbsp;
                  	Từ ngày 
                     <input name="start" type="text" id="start_time"  value="<?php echo $_POST['start'];?>"/> 
                       <script type="text/javascript">
							$(function()
							{
								var arrayDayName=["CN","Hai","Ba","Tư","Năm","Sáu","Bảy"];
								var arrayMonthName=["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"];
								
								$('#start_time').datepicker({
									yearRange: 'c-12:c+8',
									changeMonth: true,
									changeYear: true,
									dateFormat: 'dd-mm-yy',
									showAnim: 'slideDown',
									monthNamesShort:arrayMonthName,
									dayNamesMin:arrayDayName
								});										
							});	
						</script>
                     Đến ngày
                      <input name="end" type="text" id="end_time"  value="<?php echo $_POST['end'];?>"/> 
                         <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js"></script> 
                      <script type="text/javascript">
							$(function()
							{
								var arrayDayName=["CN","Hai","Ba","Tư","Năm","Sáu","Bảy"];
								var arrayMonthName=["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"];
								
								$('#end_time').datepicker({
									yearRange: 'c-12:c+8',
									changeMonth: true,
									changeYear: true,
									dateFormat: 'dd-mm-yy',
									showAnim: 'slideDown',
									monthNamesShort:arrayMonthName,
									dayNamesMin:arrayDayName
								});										
							});	
						</script>
                    <input type="submit" name="button" id="button" value="Tìm kiếm" /></td>
                </tr>
                <tr>
                  <td style="padding:7px"><table width="100%" border="1" cellspacing="0" cellpadding="0" class="list_border">
                    <tr>
                      <td width="3%" class="list_title">#</td>
                      <td width="3%" class="list_title"> <input type="checkbox" name="chkAll" id="chkAll"  value="" onclick="CheckUncheckAll();" /></td>
                      <td width="15%" class="list_title">Tên dịch vụ</td>
                      <td width="15%" class="list_title">Domain</td>
                      <td width="10%" class="list_title">Loại dịch vụ</td>
                       <td width="10%" class="list_title">Ngày đăng ký</td>
                      <td width="10%" class="list_title">Ngày hết hạn</td>
                      <td width="15%" class="list_title">Mã khách hàng</td>
                      <td width="3%" class="list_title">Duyệt</td>
                     
                      <td width="7%" class="list_title">Trạng thái</td>
                    </tr>
                 
                 <?php
$search=$_POST['txtsearch'];
$start=$_POST['start'];
$end=$_POST['end'];
?>
                    <?php
					
					
	$sqlstring="select * from 
							tb_services
							inner join tb_services_type
							on tb_services.services_type_id = tb_services_type.services_type_id
							inner join tb_account
							on tb_services.parent_account_id = tb_account.account_id
							 "; 
	
	
	
	if($search!=""){$sqlstring.=" and services_name like '%$search%'";}
	if(isset($start))
	{
		if($start!="")
		{
			$sqlstring.=" and end_time >= '".strtotime($start)."'" ;
		}
	}
	if(isset($end))
	{
		if($end!="")
		{
			$sqlstring.=" and end_time <= '".strtotime($end)."'" ;
		}
	}
	$qr12=mysql_query($sqlstring);
	$n_record=mysql_num_rows($qr12); 
	$p=$_SESSION['page'];
	$n=$_GET['n'];
	include 'phantrang.php';
	$sqlstring.=" order by services_id desc";
	if ($n!='all'){$sqlstring.=" limit $s,$p";}
	$qr1=mysql_query($sqlstring); 
	$i=0;
	while($row=mysql_fetch_array($qr1)) 
	{ $i=$i+1;
	//echo substr($row['ngayhethan'],3,2).'<br>';
	
	
  ?>
                    <tr  onmouseover="this.bgColor='#ffffdd'" onmouseout="this.bgColor=''" style="cursor:hand;<?php if($i%2){echo 'background:#D9ECFD';}else {echo 'background:#fff';}?>">
                      <td align="center" style="height:30"><?=$i?></td>
                      <td align="center">
                      <input type="checkbox" name="industry<?=$i?>" id="industry<?=$i?>"  value="<?php echo $row['services_id']?>"/></td>
                      <td class="link-edit"><a href="index.php?progid=6&services=sua&id=<?=$row['services_id']?>"><?php echo $row['services_name']?></a></td> 
                      <td align="center"> <?php echo $row['domain_name'];?> </td>
                      <td align="center" style="padding-left:5px; line-height:18px"><?php echo $row['services_type_name'];?> </td>
                      <td align="center"> <?php echo date('d-m-Y',$row['start_time']);?> </td>
                      <td align="center"> <?php echo date('d-m-Y',$row['end_time']);?> </td>
                      <td align="center" style="padding-left:5px; padding-right:5px; line-height:18px;"><?php echo $row['account_code'];?> <br /> (<?php echo $row['account_name'];?>) </td>
                      <td align="center"><?php if($row['services_status']==1){?><img src="images/tick.png" /><? }else{?><img src="images/publish_x.png" /><? }?></td>
                      
                      <td align="center">
					  	<?php 
							if($row['trangthai']==0){echo '<span style="color:#06F"> Đang sử dụng </span>';}
							if($row['trangthai']==2 or $row['trangthai']==3){echo '<span style="color:#F60"> Sắp hết hạn
									<img src="../images/mail.png" title="đã gửi mail '.$row['count_sendmail'].' lần "/> </span> <span style="color:#f00"> '.$row['count_sendmail'].'</span> ';}
							if($row['trangthai']==-1 or $row['trangthai']==-2){echo ' <span style="color:#f00"> Đã hết hạn 
									
									</span>';
								?>
                                	 <img src="../images/mail.png" title="đã gửi mail <?php echo $row['count_sendmail'];?> lần"/> <span style="color:#f00"><?php echo $row['count_sendmail'];?></span>
                                <?php	
								}
					  	?>
                      </td>
                    </tr>
<? }?>
                  </table></td>
                </tr>
                <tr>
                  <td><? view_page('index.php?progid=6'); ?></td>
                </tr>
              </table>
              <input type="hidden" name="count" id="count" value="<?=$i?>"  />
                        </form>
            </td>
            <td width="1" background="images/dot.png"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" height="6" ><img src="images/j_crn_bl_med.png" width="6" height="6" /></td>
            <td  background="images/j_crn_b_med.png" width="100%"></td>
            <td width="6" height="6" ><img src="images/j_crn_br_med.png" width="6" height="6" /></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</td>
  </tr>
</table>
<div  style="padding-left:20px;"> 
	<span><a href="#" onclick="return doSaveJobs('index.php?progid=6&services=saphethan','Vui lòng chọn một bản ghi từ danh sách bên dưới')">  Sắp hết hạn </a></span>&nbsp;  
	<span><a  href="#" onclick="return doSaveJobs('index.php?progid=6&services=dahethan','Vui lòng chọn một bản ghi từ danh sách bên dưới')"> Đã hết hạn </a></span>
</div>